package ace.module.oauth2.server.core.impl.converter.impl;

import ace.module.oauth2.server.core.impl.converter.ClientSettingsFromJsonConverter;
import ace.module.oauth2.server.core.impl.converter.Oauth2ObjectJsonConverter;
import java.util.Map;
import lombok.AllArgsConstructor;
import org.springframework.security.oauth2.server.authorization.settings.ClientSettings;
import org.springframework.stereotype.Component;

/**
 * @author caspar
 * @date 2023/10/12 11:50
 */
@AllArgsConstructor
@Component
public class ClientSettingsFromJsonConverterImpl implements ClientSettingsFromJsonConverter {
  private final Oauth2ObjectJsonConverter oAuth2ObjectJsonConverter;

  @Override
  public ClientSettings convert(String source) {
    Map<String, Object> clientSettingsMap = oAuth2ObjectJsonConverter.toMap(source);
    return ClientSettings.withSettings(clientSettingsMap).build();
  }
}
